Skip to content

Upgrade to .NET 10, Aspire 13, and System.CommandLine 2.0#794

Merged
tjementum merged 11 commits intomainfrom
pp-629-upgrade-to-net-10
Nov 23, 2025
Merged

Upgrade to .NET 10, Aspire 13, and System.CommandLine 2.0#794
tjementum merged 11 commits intomainfrom
pp-629-upgrade-to-net-10

Conversation

@tjementum
Copy link
Member

@tjementum tjementum commented Nov 23, 2025

Summary & Motivation

Upgrade the codebase to .NET 10 and adopt new C# 14 language features.

  • Update all projects to target .NET 10.
  • Update to Aspire 13 and use Aspire.Hosting.JavaScript over the deprecated Aspire.Hosting.NodeJS.
  • Update Docker images to use secure chiseled base images: mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled-extra for projects using Entity Framework, and mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled for AppGateway.
  • Upgrade System.CommandLine to 2.0.0 and migrate from NamingConventionBinder to the new SetAction API.
  • Convert extension methods to C# 14 extension members syntax using extension(Type param).
  • Update properties with backing fields to use the new field keyword.
  • Remove params keyword from extension methods to avoid Roslyn compiler errors (dotnet/roslyn#80024).

Downstream projects

Downstream projects must make the following changes to align with this upgrade:

  1. Update all *.csproj files to target .NET 10:

    - <TargetFramework>net9.0</TargetFramework>
    + <TargetFramework>net10.0</TargetFramework>
  2. Update all WebApp .esproj files (e.g., application/your-self-contained-system/WebApp/YourSystem.WebApp.esproj):

    - <TargetFrameworkMoniker>net9.0</TargetFrameworkMoniker>
    + <TargetFrameworkMoniker>net10.0</TargetFrameworkMoniker>
  3. Update Dockerfiles to use secure chiseled base images:

    • For API and Workers projects (that use Entity Framework):
      - FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine
      - RUN apk add --no-cache icu-libs
      - ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
      + FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled-extra
  4. Remove WebApp .esproj references from AppHost in application/AppHost/AppHost.csproj:

    - <ProjectReference Include="..\your-self-contained-system\WebApp\YourSystem.WebApp.esproj"/>

    With Aspire.Hosting.JavaScript using the new AddJavaScriptApp() over AddNpmApp() eliminates the need for .esproj project references in AppHost.

  5. Update application/your-self-contained-system/Tests/EndpointBaseTest.cs to use the new field keyword for auto-implemented properties with backing fields:

    - private ServiceProvider? _provider;
    
    - protected ServiceProvider Provider => _provider ??= Services.BuildServiceProvider();
    + protected ServiceProvider Provider => field ??= Services.BuildServiceProvider();

    Also update the reference in EndpointBaseTest constructor:

    - using var serviceScope = Provider.CreateScope();
    + using var serviceScope = Provider!.CreateScope();
  6. Fix extension method calls in SharedKernel that had the params keyword removed due to Roslyn issue #80024:

    • Methods like AddApiServices(), AddSharedInfrastructure(), AddWorkerServices(), and similar extension methods in SharedKernel no longer use params for their assembly parameters.
    • Update calls to pass arrays explicitly: services.AddApiServices([assembly1, assembly2]) instead of services.AddApiServices(assembly1, assembly2).
    • Example from application/your-self-contained-system/Api/Program.cs:
      - builder.Services.AddApiServices(Assembly.GetExecutingAssembly(), typeof(Configuration).Assembly);
      + builder.Services.AddApiServices([Assembly.GetExecutingAssembly(), typeof(Configuration).Assembly]);
  7. If you have a custom developer CLI, update any custom commands to use System.CommandLine 2.0.0 syntax:

    • Replace System.CommandLine.NamingConventionBinder with System.CommandLine.Invocation.
    • Replace Handler = CommandHandler.Create<...>(Execute) with this.SetAction(parseResult => Execute(...)).
    • Update option definitions from inline construction to explicit Options.Add() calls.
    • See developer-cli/Commands/CheckCommand.cs for a complete example.
  8. Optional: Adopt C# 14 features:

    • Convert extension methods to use the new extension(Type param) syntax (see application/shared-kernel/SharedKernel/ApiResults/ApiResultExtensions.cs for examples).
    • Update properties with explicit backing fields to use the new field keyword (see the EndpointBaseTest.cs change in step 5).
  9. Developers need to install .NET 10 SDK. Aspire's AppHost automatically handles SSL certificate creation and management when running the application locally. If you encounter certificate-related errors after upgrading, the AppHost will regenerate certificates automatically on the next run.

Checklist

  • I have added tests, or done manual regression tests
  • I have updated the documentation, if necessary

@tjementum tjementum self-assigned this Nov 23, 2025
@tjementum tjementum requested a review from a team as a code owner November 23, 2025 21:18
@tjementum tjementum added Enhancement New feature or request Deploy to Staging Set this label on pull requests to deploy code or infrastructure to the Staging environment labels Nov 23, 2025
@linear
Copy link

linear bot commented Nov 23, 2025

@tjementum tjementum moved this to 🏗 In Progress in Kanban board Nov 23, 2025
@tjementum tjementum force-pushed the pp-629-upgrade-to-net-10 branch from 4b4a827 to f19e6dd Compare November 23, 2025 21:29
@tjementum tjementum force-pushed the pp-629-upgrade-to-net-10 branch from f19e6dd to 1f935d2 Compare November 23, 2025 23:06
@tjementum tjementum force-pushed the pp-629-upgrade-to-net-10 branch from 1f935d2 to b53873f Compare November 23, 2025 23:25
@sonarqubecloud
Copy link

@tjementum tjementum removed the Deploy to Staging Set this label on pull requests to deploy code or infrastructure to the Staging environment label Nov 23, 2025
@tjementum tjementum merged commit c094a88 into main Nov 23, 2025
28 checks passed
@tjementum tjementum deleted the pp-629-upgrade-to-net-10 branch November 23, 2025 23:46
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in Kanban board Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant